/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dreamwar.model.POJO;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Berto_Romero
 */
@Entity
@Table(name = "army", catalog = "dreamwar_sif", schema = "")
@NamedQueries({
    @NamedQuery(name = "Army.findAll", query = "SELECT a FROM Army a"),
    @NamedQuery(name = "Army.findByIdArmy", query = "SELECT a FROM Army a WHERE a.idArmy = :idArmy"),
    @NamedQuery(name = "Army.findByArmyName", query = "SELECT a FROM Army a WHERE a.armyName = :armyName")})
public class Army implements Serializable {
    @Transient
    private final PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id_army")
    private Integer idArmy;
    @Column(name = "army_name")
    private String armyName;

    public Army() {
    }

    public Army(Integer idArmy) {
        this.idArmy = idArmy;
    }

    public Integer getIdArmy() {
        return idArmy;
    }

    public void setIdArmy(Integer idArmy) {
        Integer oldIdArmy = this.idArmy;
        this.idArmy = idArmy;
        changeSupport.firePropertyChange("idArmy", oldIdArmy, idArmy);
    }

    public String getArmyName() {
        return armyName;
    }

    public void setArmyName(String armyName) {
        String oldArmyName = this.armyName;
        this.armyName = armyName;
        changeSupport.firePropertyChange("armyName", oldArmyName, armyName);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idArmy != null ? idArmy.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Army)) {
            return false;
        }
        Army other = (Army) object;
        return (this.idArmy != null || other.idArmy == null) && (this.idArmy == null || this.idArmy.equals(other.idArmy));
    }

    @Override
    public String toString() {
        return "dreamwar.presentation.view.Army[ idArmy=" + idArmy + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
